package com.lotus.lqmp.service.common.enums;

import java.util.Arrays;

/**
 * description
 * @author Shiheng.Liu1
 * @since 2022/03/18 10:56
 */
public enum YesNoEnum {

    YES(0, "是"),
    NO(1, "否");

    private Integer code;
    private String value;

    YesNoEnum(Integer code, String value) {
        this.code = code;
        this.value = value;
    }


    public Integer code() {
        return this.code;
    }

    public String value() {
        return this.value;
    }

    public String getValue() {
        return value;
    }

    public Integer getCode() {
        return code;
    }

    public static YesNoEnum enumFromKey(Integer code) {
        if (code == null) {
            return null;
        }
        return Arrays.stream(YesNoEnum.values()).filter(s -> s.code().equals(code))
            .findFirst().orElse(null);
    }

}
